# -*- coding: utf-8 -*-
__author__ = 'gongqf'
import cx_Oracle
from flask import Flask, g
from config import DATABASE
# import os
# os.environ["NLS_LANG"] = "SIMPLIFIED CHINESE.ZHS16GBK"

app = Flask(__name__)
app.config.from_object('config')

def CloseDB():
    if hasattr(g, 'db'):
        g.db.close()
        g.con.close()


def connect_db():
    con = cx_Oracle.connect(DATABASE)
    cur = con.cursor()
    return cur, con

@app.before_request
def before_request():
    g.db, g.con = connect_db()
    # g.db.execute("PRAGMA foreign_keys=ON")


@app.teardown_request
def teardown_request(exception):
    CloseDB()


from gis import views, models